<template>
  <view class="forget-container">
    <!-- 手机号输入区域 -->
    <view class="popup-content">
      <view class="popup-icon">
        <image
          class="status-icon"
          :src="getStatusImage(audit_status).image"
          mode="aspectFit"
        ></image>
      </view>
      <view class="popup-title">{{
        getStatusImage(audit_status, remark).text
      }}</view>

      <!-- 确定按钮 -->
      <button
        class="confirm-btn"
        @tap="resetPasswordData"
        v-if="audit_status !== '1'"
        @click="nav"
      >
        {{ audit_status === "3" ? "重新提交" : "进入店铺" }}
      </button>
    </view>
  </view>
</template>

<script setup>
import { ref } from "vue";
import { onLoad, onUnload } from "@dcloudio/uni-app";

const getStatusImage = (audit_status, remark = "") => {
  const Image = {
    1: "https://cphimg.leyoo888.com/dev/upload/supplier/2025-05-07/1746605107561.png",
    2: "https://cphimg.leyoo888.com/dev/upload/supplier/2025-05-07/1746597449604.png",
    3: "https://cphimg.leyoo888.com/dev/upload/supplier/2025-05-07/1746597453265.png",
  };
  const text = {
    1: "供应商审核中,请耐心等待",
    2: "恭喜你,审核已通过",
    3: `审核不通过,原因：${remark}`,
  };
  return { image: Image[audit_status] || "", text: text[audit_status] || "" };
};

const nav = () => {
  switch (audit_status.value) {
    case "1":
      break;
    case "2":
      uni.redirectTo({
        url: "/pagesShop/store/storeHome",
      });
      break;
    case "3":
      uni.redirectTo({
        url: `/pages/login/storeShare?id=${supplier_info_id.value}&edit=1`,
      });
      break;
  }
};
// 组件销毁时清除定时器
onUnload(() => {});
const audit_status = ref(null);
const supplier_info_id = ref(null);
const remark = ref("");
onLoad((options) => {
  if (options.audit_status) {
    audit_status.value = options.audit_status;
    supplier_info_id.value = options.supplier_info_id;
    if (options.audit_remarks) {
      remark.value = options.audit_remarks;
    }
  }
});
</script>

<style lang="scss" scoped>
.forget-container {
  padding: 30rpx;
}

.popup-content {
  position: absolute;
  top: 27%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 80%;
  background-color: #ffffff;
  border-radius: 10rpx;
  padding: 40rpx 30rpx;
  display: flex;
  flex-direction: column;
  align-items: center;

  .popup-icon {
    margin-bottom: 30rpx;

    .status-icon {
      width: 100rpx;
      height: 100rpx;
    }
  }

  .popup-title {
    font-size: 32rpx;
    color: #333333;
    font-weight: 500;
    margin-bottom: 60rpx;
    text-align: center;
  }

  .popup-info {
    width: 100%;
    margin-bottom: 40rpx;

    .info-item {
      display: flex;
      margin-bottom: 15rpx;

      .info-label {
        font-size: 26rpx;
        color: #666666;
        width: 160rpx;
      }

      .info-value {
        font-size: 26rpx;
        color: #333333;
        flex: 1;
      }
    }
  }
}

.confirm-btn {
  width: 100%;
  height: 90rpx;
  line-height: 90rpx;
  text-align: center;
  background-color: #f55054;
  color: #fff;
  font-size: 32rpx;
  border-radius: 10rpx;
  margin-bottom: 50rpx;
  border: none;
}
</style>
